package fr.nantes.univ.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import fr.nantes.univ.DAO.AddressDAO;
import fr.nantes.univ.EntityBeans.Address;

@SuppressWarnings("serial")
public class DeleteAddressServlet extends HttpServlet {
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		
		response.getWriter().println(request.getPathInfo());
		
		Address address = AddressDAO.findByAddress(request.getPathInfo().substring(1));
		
		AddressDAO.delete(address);
		
		response.sendRedirect("/myaddresses");
		
	}

}
